<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网页设计2</title>
</head>
<script>
    window.onload=function(){
        var btn = document.getElementById("btn");
        btn.onclick=function(){
            var num;
            var sum;
           var length= prompt("请输入长方形的长(厘米)：");
           var height= prompt("请输入长方形的宽(厘米)："); 
         num = length * height ;
         sum = 2*length + 2*height ;
        alert("长方形的总边长是："+ sum +'\n'+ "长方形的总面积是:"+ num);
        }
    }
</script> 
<body>
    <input type='button' value="长方形总边长及面积" id='btn'>
</body>
</html>